﻿using CommonType;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S_Gridding.Domains.BasicData;
using S_Gridding.Read.Api.Command.AssemType;
using S_Gridding.Read.Api.CommandHands.AssemType;

namespace S_Gridding.Read.Api.Controllers
{
    /// <summary>
    /// 事件类型管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AssemTypeController : ControllerBase
    {
        private readonly IMediator _mediator;

        public AssemTypeController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 事件类型展示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResule<AssemTypeInfo>> ShowAssemTypeInfo([FromQuery]ShowAssemTypeCommand m)
        {
            return await _mediator.Send(m);
        }

        /// <summary>
        /// 显示事件树形信息
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<ShowTreeAssemDTO<AssemTypeInfo>>> ShowTreeInfo([FromQuery]ShowTreeCommand m)
        {
            return await _mediator.Send(m);
        }

        /// <summary>
        /// 反填事件类型管理信息
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<AssemTypeInfo> BackAssemTypeInfo([FromQuery] BackAssemTypeCommand m)
        {
            return await _mediator.Send(m);
        }
    }
}
